# 导包
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

# 导入浏览器驱动
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://news.baidu.com/")

# 元素定位+元素操作
i = 1000
while True:
    try:
        driver.find_element(By.PARTIAL_LINK_TEXT, "12岁男孩身高1.93米！青岛篮球小将梦想打进国家..").click()
        break
    except:
        driver.execute_script(f"window.scrollTo(0,{i})")
        sleep(3)
        i += 1000

# 关闭浏览器
driver.quit()
